import request from '@/utils/useRequest'
import axios from "axios";
export const httpUpload = (file) => {
    let formData = new FormData()
    formData.append('file', file)
    return request({
        url: '/upload/file',
        method: 'post',
        data: formData
    })
}
export const getCityTree = () => {
    return request({
        url: '/norms/sys/sysArea/tree',
        method: 'post'
    })
}
export const http = {
    login: (data) => {
        return request({
            url: '/user/login',
            data,
            method: 'post'
        })
    },
    logout: (data) => {
        return request({
            url: '/user/logout',
            data,
            method: 'post'
        })
    },
    stationData: {
        list: (data) => {
            return request({
                url: '/stationData/list',
                data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/stationData/updateAll',
                data,
                method: 'post'
            })
        },
    },
    // 光伏实时预测基本信息
    pvForecastRel: {
        page: (data) => {
            return request({
                url: '/pvForecastRel',
                params: data,
                method: 'get'
            })
        },
        list: (params) => {
            return request({
                url: '/pvForecastRel/list',
                params,
                method: 'get',
            })
        },
        update: (data) => {
            return request({
                url: '/pvForecastRel/updateAll',
                data,
                method: 'post'
            })
        },
    },
    // 光伏实时预测记录数据
    pvForecastRelRecord: {
        page: (data) => {
            return request({
                url: '/pvForecastRelRecord',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/pvForecastRelRecord/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/pvForecastRelRecord/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/pvForecastRelRecord',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/pvForecastRelRecord/' + id,
                method: 'delete'
            })
        }
    },
    // 光储能协调基础信息
    pvCoordination: {
        list: (data) => {
            return request({
                url: '/pvCoordination/list',
                data,
                method: 'get',
            })
        },
        update: (data) => {
            return request({
                url: '/pvCoordination/updateAll',
                data,
                method: 'post'
            })
        },
    },
    // 光伏实时预测记录数据
    pvCoordinationRecord: {
        page: (data) => {
            return request({
                url: '/pvCoordinationRecord',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/pvCoordinationRecord/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/pvCoordinationRecord/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/pvCoordinationRecord',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/pvCoordinationRecord/' + id,
                method: 'delete'
            })
        }
    },
    energyData: {
        list: (data) => {
            return request({
                url: '/energyData/list',
                data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/energyData/updateAll',
                data,
                method: 'post'
            })
        },
    },
    energyTimeData: {
        exportPage: (data) => {
            return request({
                url: '/energyTimeData/exportPage',
                data,
                method: 'post'
            })
        },
        page: (params) => {
            return request({
                url: '/energyTimeData',
                params,
                method: 'get'
            })
        },
        list: (params) => {
            return request({
                url: '/energyTimeData/list',
                params,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/energyTimeData/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/energyTimeData',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        upload: (file) => {
            let formData = new FormData()
            formData.append('file', file)
            return request({
                url: '/energyTimeData/upload',
                method: 'post',
                data: formData
            })
        },
        del: (id) => {
            return request({
                url: '/energyTimeData/' + id,
                method: 'delete'
            })
        }
    },
    dataQuery: {
        page: (data) => {
            return request({
                url: '/dataQuery',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/dataQuery/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/dataQuery/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/dataQuery',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/dataQuery/' + id,
                method: 'delete'
            })
        }
    },
    alarm: {
        page: (data) => {
            return request({
                url: '/alarm',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/alarm/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/alarm/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/alarm',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/alarm/' + id,
                method: 'delete'
            })
        }
    },
    system: {
        page: (data) => {
            return request({
                url: '/system',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/system/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/system/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/system',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/system/' + id,
                method: 'delete'
            })
        }
    },
    role: {
        page: (data) => {
            return request({
                url: '/role',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/role/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/role/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/role',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/role/' + id,
                method: 'delete'
            })
        },
        read: ({id}) => {
            return request({
                url: '/role/' + id,
                method: 'get'
            })
        },
    },
    user: {
        page: (data) => {
            return request({
                url: '/user',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/user/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/user/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/user',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: ({id}) => {
            return request({
                url: '/user/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/user/' + id,
                method: 'delete'
            })
        }
    },
}